<?php
  require(dirname(__FILE__)."/../RequestMethod.php");
  require(dirname(__FILE__)."/../model/StudentManageModel.php");
  class ResolveController extends RequestMethod{
      private $userModel = null;


      /**
      *构造函数，实例化对象
      */
      public function __construct($urlArr){
          $this->StudentModel = new StudentModel();
          parent::__construct($urlArr);
      }
	    /**
      *GET请求
      */
      public function doGet(){
        $action = $_GET['action'];
		echo $action;
        // $result = $this->StudentModel->findUserList($action);
	    // print_r($result);
      }
	    /**
      *POST请求
      */
      public function doPost(){
     $action = $_POST['act'];
          switch ($action) {
            case 'list':
              $result=$this->StudentModel->findUserList(null);
              break;
            case 'add':
              $user['UserGroupID'] = $_POST['roll'];
              $user['ClassID'] = $_POST['stu_id'];
              $user['StudentNO'] = $_POST['name'];
              $result = $this->StudentModel->addUser($user);
              break;
            case 'mod':
              $user = $_POST['user'];
              $result = $this->userModel->update($user);
              break;
            case 'query':
              $where[] = $_POST['where_1'];
              $where[] = $_POST['where_2'];
              $where[] = $_POST['where_3'];
              $result = $this->StudentModel->query($where);
              break;
            case 'status':
              $status = $_POST['status'];
              $result = $this->userModel->changeUserStatus($status);
              break;
            case 'passWord':
              $userId = $_POST['userId'];
              $passWord = $_POST['passWord'];
              $result = $this->userModel->changePassWord($userId,$passWord);
              break;  
		    case 'login':
              $userId = $_POST['userName'];
              $PWD = $_POST['PWD'];
              $code = $_POST['code'];
              $result = $this->userModel->login($userId,$PWD,$code);
              break;
          }
        echo json_encode($result);
      }
      }